<!--
 * @Author: wangming
 * @Date: 2022-04-18 11:49:15
 * @LastEditors: wangming
 * @LastEditTime: 2022-04-29 17:59:16
 * @FilePath: /hanma-application-designer-fed/src/pages/designUniversal/__components__/dynamicForm/rightModel/components/hlTableList/table_relation.vue
 * @Description: 
-->
<template>
  <div class="mb10">
    <div class="ks-row-middle lh1 mb10">
      <div class="mr10 g3">关联字段</div>
      <i
        class="el-icon-circle-plus-outline iconcolor f20 poi"
        @click="addTag"
      ></i>
    </div>
    <el-table size="mini" :data="value.relationForm" border style="width: 100%">
      <el-table-column prop="chidlrenKey" label="关联字段"> </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <i
            class="el-icon-edit poi iconcolor"
            @click="editTag(scope.row, scope.$index)"
          ></i>
          <el-popconfirm
            placement="top"
            title="确定删除该关联字段吗？"
            @confirm="delTag(scope.$index)"
          >
            <i slot="reference" class="el-icon-delete ml10 poi del"></i>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import addRelationCode from "./__components__/addRelationCode/index";
import basicmixins from "../basicmixins";
import { getHmentitymodelList } from "@/apis/paas/HmEntityModelController.js";
export default {
  mixins: [basicmixins],
  data() {
    return {};
  },
  created() {},
  mounted() {},
  methods: {
    delTag(index) {
      this.value.relationForm.splice(index, 1);
    },
    async editTag(form, index) {
      let modelList = await getHmentitymodelList({
        activated: true,
        modelKey: this.value.__config.modelCode,
      });
      let value = { modelList };
      addRelationCode.editForm(value, form).then((res) => {
        this.value.relationForm.splice(index, 1, res);
      });
    },
    async addTag() {
      let modelList = await getHmentitymodelList({
        activated: true,
        modelKey: this.value.__config.modelCode,
      });
      let value = { modelList };
      addRelationCode.addForm(value).then((res) => {
        this.value.relationForm.push(res);
      });
    },
  },
};
</script>

<style scoped lang="scss">
</style>
